package com.huanwei.cc.ui;

import android.annotation.SuppressLint;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.TextView;

import com.huanwei.cc.base.MyApplication;
import com.huanwei.cc.R;
import com.huanwei.cc.db.Z_MSGDao;

import me.shaohui.bottomdialog.BaseBottomDialog;

/**
 * Created by shaohui on 16/10/12.
 */

@SuppressLint("ValidFragment")
public class EditTextDialog extends BaseBottomDialog {

    private EditText mEditText;
    String name;
    String xueke;

    @SuppressLint("ValidFragment")
    public EditTextDialog(String name, String xueke) {
        this.name = name;
        this.xueke = xueke;
    }

    @Override
    public int getLayoutRes() {
        return R.layout.dialog_edit_text;
    }

    @Override
    public void bindView(View v) {
        mEditText = (EditText) v.findViewById(R.id.edit_text);
        TextView baocun = (TextView) v.findViewById(R.id.baocun);
        baocun.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Log.e("888", name);
                Z_MSGDao z_msgDao = new Z_MSGDao(MyApplication.getInstance());
                z_msgDao.addMSG(name, xueke, mEditText.getText().toString());
                dismiss();
            }
        });
        mEditText.post(new Runnable() {
            @Override
            public void run() {
                InputMethodManager imm =
                        (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.showSoftInput(mEditText, 0);
            }
        });
    }

    @Override
    public float getDimAmount() {
        return 0.9f;
    }

    @Override
    public void onResume() {
        super.onResume();
    }
}
